﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;

[assembly: WebResource("IRC.IRepairClouds.WebClient.Controls.Common.RadComboCheckBoxList.debug.js", "text/javascript")]
[assembly: WebResource("IRC.IRepairClouds.WebClient.Controls.Common.RadComboCheckBoxList.js", "text/javascript")]

namespace IRC.IRepairClouds.WebClient.Controls.Common
{
    public partial class RadComboCheckBoxList : ScriptControl
    {
        public class Item
        {
            public string Name { get; set; }
            public string Value { get; set; }
        }

        List<Item> _items = new List<Item>();

        protected override void OnPreRender(EventArgs e)
        {
            HiddenFieldClient.Value = _items.JSON_Serialize(false);
            base.OnPreRender(e);
        }

        public static IEnumerable<ScriptReference> GetScriptReferencesStatic()
        {
            yield return new ScriptReference("IRC.IRepairClouds.WebClient.Controls.Common.RadComboCheckBoxList.js", "IRC.IRepairClouds.WebClient");
        }

        public override IEnumerable<ScriptDescriptor> GetScriptDescriptors()
        {
            ScriptControlDescriptor descriptor = new ScriptControlDescriptor("IRepairClouds.Controls.Common.RadComboCheckBoxList", holder.ClientID);
            yield return descriptor;
        }

        public override IEnumerable<ScriptReference> GetScriptReferences()
        {
            return GetScriptReferencesStatic();
        }

        [PersistenceMode(PersistenceMode.Attribute)]
        public Unit Width
        {
            get { return RadComboBoxInner.Width; }
            set { RadComboBoxInner.Width = value; }
        }

        [PersistenceMode(PersistenceMode.Attribute)]
        public string EmptyMessage
        {
            get { return RadComboBoxInner.EmptyMessage; }
            set { RadComboBoxInner.EmptyMessage = value; }
        }

        [PersistenceMode(PersistenceMode.InnerProperty)]
        public List<Item> Items
        {
            get { return _items; }
        }
    }
}